package com.ruoyi.project.mobile.jiaqin;

import com.ruoyi.common.utils.R;
import com.ruoyi.project.jiaqin.region.domain.Region;
import com.ruoyi.project.jiaqin.region.service.IRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * 行政区划
 */
@RestController
@RequestMapping("/api/jq/region")
public class ApiRegionController {

    @Autowired
    private IRegionService iRegionService;

    /**
     * 获取省
     * @return
     */
    @GetMapping("/getProvince")
    public R getProvince(){
        HashMap<String,Object> map = new HashMap<>();
        List<Region> list = iRegionService.selectRegionProvinceList();
        map.put("data",list);
        return R.ok(map);
    }

    /**
     * 根据父ID获取市或县
     * @return
     */
    @GetMapping("/getCityOrArea")
    public R getCityOrArea(Integer pid){
        HashMap<String,Object> map = new HashMap<>();
        List<Region> list = iRegionService.selectRegionCityOrAreaList(pid);
        map.put("data",list);
        return R.ok(map);
    }



}
